package com.ra.landlord;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.ra.system.Version;

/**
 * TODO:  重构： 仅用于记录Tenant和Room的关系?
 * 
 * 用户房间关系， 外加合约关系冗余
 * 
 *
 */
@Entity
@Table(name = "ra_room_tenantuser")
public class TenantRoomRelation implements Version, LandlordOwner{

	private Integer id;

	private Agreement agreement;
	
	private TenantUser tenantUser;
	
	private Room room;
	
	// 
	// 0 - 没有关系， 1 - 房东房间关系， 2 - 管理员房间关系， 3 - 租客房间关系
	private Integer type;

	// 租房合约有效性标志
	// 0 - 有效， 1 - 无效
	private Integer extType;
	
	// 数据删除标志
	// 0 - 被删除， 1 - 有效
	private Integer status;
	
	private Integer version;
	
	private LandlordOwnerUser landlordUser;
	
	@Id
	@GeneratedValue
	@Column(name = "relationId")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "user_id")
	public TenantUser getTenantUser() {
		return tenantUser;
	}

	public void setTenantUser(TenantUser tenantUser) {
		this.tenantUser = tenantUser;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "agreement_id")
	public Agreement getAgreement() {
		return agreement;
	}

	public void setAgreement(Agreement agreement) {
		this.agreement = agreement;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "room_id")
	public Room getRoom() {
		return room;
	}

	public void setRoom(Room room) {
		this.room = room;
	}

	@Column(name = "relation_type")
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@Column(name = "relation_type_ext")
	public Integer getExtType() {
		return extType;
	}

	public void setExtType(Integer extType) {
		this.extType = extType;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "createuserid")
	public LandlordOwnerUser getLandlordUser() {
		return landlordUser;
	}

	public void setLandlordUser(LandlordOwnerUser landlordUser) {
		this.landlordUser = landlordUser;
	}
	
	@Column(name = "version_id")
	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@Column(name = "data_status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
}
